package com.CST.controller.zx;

import com.CST.common.api.ResultObject;
import com.CST.entity.cb.BdEnumdetail;
import com.CST.service.zx.IZxUFIDADepartmentService;
import com.CST.util.PageHelperTool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 伍文毅
 * @Date 2023 02 28 10 40
 **/
@Api(tags = {"用友科室数据对照"})
@RestController
@RequestMapping("/bdEnumdetail")
public class ZxUFIDADepartmentController {


    @Resource
    private IZxUFIDADepartmentService IZxUFIDADepartmentService;

    @GetMapping("/page")
    @ApiOperation("分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "用友科室名称",name = "edExtraFirstDescription",required = false),
            @ApiImplicitParam(value = "系统名称",name = "edExtraSecondDescription",required = false),
            @ApiImplicitParam(value = "状态",name = "rowStatus",required = false),
            @ApiImplicitParam(value = "第几页",name = "pageIndex",required = true),
            @ApiImplicitParam(value = "科室-用友对应（固定）",name = "edName",required = true),
            @ApiImplicitParam(value = "每页几条数据",name = "pageSize",required = true)
    })
    public ResultObject<List<BdEnumdetail>> page(@RequestBody BdEnumdetail bdEnumdetail) {
        List<BdEnumdetail> bdEnumdetails = IZxUFIDADepartmentService.myPage(bdEnumdetail);
        return ResultObject.successReturn(
                PageHelperTool.excutePageInfo(bdEnumdetails, bdEnumdetail.getPageIndex(), bdEnumdetail.getPageSize()));
    }

    @GetMapping("/selectEdName")
    @ApiOperation("查询科室名称")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "第几页",name = "pageIndex",required = true),
            @ApiImplicitParam(value = "科室-用友对应（固定）",name = "edName",required = true)
    })
    public ResultObject<List<BdEnumdetail>> selectEdName(@RequestBody BdEnumdetail bdEnumdetail) {
        if (bdEnumdetail.getPageSize() == 0){
            bdEnumdetail.setPageSize(20);
        }
        List<BdEnumdetail> bdEnumdetails = IZxUFIDADepartmentService.selectEdName(bdEnumdetail);
        return ResultObject.successReturn(
                PageHelperTool.excutePageInfo(bdEnumdetails, bdEnumdetail.getPageIndex(), bdEnumdetail.getPageSize()));
    }

//    科室逻辑删除没找到逻辑删除字段
}
